<template>

    <div style="width: 100%;height: 100%;">

        <img :src="img" style="width: 100%;"/>
      
    </div>

</template>

<script>
  import axios from 'axios';
  import global from '../../../utils/global'
  import wx from 'weixin-js-sdk'

export default {
	

	data (){
		return{
			
			access_token:'',
			img:'',
			parentUid:0
			
		}
	},
		
	methods:{
		
		//
	    getQrcode(){
	    	
	    	var that = this;
	        axios.get(global.api.user.qrCode,{
	            params: {
	                uuid: localStorage.getItem('carWashUuid')
	            }
	        })

	        .then(function(res){
	            
	            console.log('二维码=='+JSON.stringify(res.data.data.pic_url));
	            that.img = res.data.data.pic_url,
	            that.parentUid = res.data.data.parentUid
	           
	        })

	        .catch(function(res){
	            console.log(res);
	        })
		},
	    
	    //获取地址栏信息
		getUrlStr(name){
			
	      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
	      if(reg.test(window.location.href)){
	        return unescape(RegExp.$2.replace(/\+/g," "))
	      }
	      return undefined
	    },

	   washShare(){

	        var that = this;
	        var pathUrl = window.location.href;
	        pathUrl = Base64.encode(pathUrl);
	        axios.get(global.api.user.jssdk,{
	            params: {
	                uuid: localStorage.getItem('carWashUuid'),
	                url: pathUrl,
	            }
	        })
	        .then(function(res){
	            // console.log("=============share==============");
	            console.log(res);
	            wx.config({
	                debug: true,
	                appId: res.data.content.appId,
	                timestamp: res.data.content.timestamp,
	                nonceStr: res.data.content.nonceStr,
	                signature: res.data.content.signature,
	                jsApiList: ['updateAppMessageShareData','updateTimelineShareData','onMenuShareTimeline','onMenuShareAppMessage']
	            });
	            wx.ready(function(res){
	                var obj = {  //分享给朋友
	                    title: 'e歌上门洗车',
	                    desc: '欢迎关注e歌无水洗车！e歌无水洗车,您身边的洗车专家！',
	                    link: global.api.baseurl+'#/?parentUid='+that.parentUid,
	                    imgUrl: 'https://newzhouzi.fxm365.com/addons/zjhj_mall/core/web/temp/20180815160427.jpg',
	                    success: function () {
	                        console.log("分享给朋友成功！");
	                    },
	                    fail: function () {
	                        console.log("分享给朋友失败！");
	                    }
	                }
	                var objAll = {  //分享到朋友圈
	                    title: 'e歌上门洗车',
	                    link: global.api.baseurl+'#/?parentUid='+that.parentUid,
	                    imgUrl: '/assets/img/timg.jpg',
	                    success: function () {
	                        console.log("分享到朋友圈成功！");
	                    },
	                    fail: function () {
	                        console.log("分享到朋友圈失败！");
	                    }
	                }
	                wx.onMenuShareAppMessage(obj);  //分享给朋友
	                wx.onMenuShareTimeline(objAll);  //分享到朋友圈
	            });
	            wx.error(function(res){
	                console.log(res);
	            })
	        })
	        .catch(function(res){
	            console.log(res);
	        })
        },
		
	},
	
	mounted(){
		
		this.getQrcode();
		this.washShare();
		
	}
}

</script>

<style>
	
</style>